babl: avoid negative degree when shrinking a zero polynomial
authorEll <ell_se@yahoo.com>
Sun, 24 Sep 2017 17:43:02 +0000 (13:43 -0400)
committerEll <ell_se@yahoo.com>
Sun, 24 Sep 2017 17:54:45 +0000 (13:54 -0400)
When shrinking a zero polynomial, avoid trying to set its degree
to a negative value, and just keep it at 0, which is the minimal
degree we support.

Note that this also happens for polynomials whose coefficients are
all NaN, as is the case in bug 788093, so they also become zero
polynomials after shrinking, incidentally.

babl/babl-polynomial.c

index d51685dda58867b3214480e219896cf85c441631..c9f195b73bf9b2748cd6e18fd3dfac604804e6be 100644 (file)
@@ -190,7 +190,11 @@ babl_polynomial_shrink (BablPolynomial *poly)
         break;
     }
 
-  if (i > 0)
+  if (i == poly->degree + 1)
+    {
+      babl_polynomial_reset (poly, poly->scale);
+    }
+  else if (i > 0)
     {
       memmove (poly->coeff, &poly->coeff[i],
                (poly->degree - i + 1) * sizeof (double));